import static org.junit.Assert.*;

import javax.swing.ImageIcon;
import javax.swing.JSlider;

import org.junit.Test;


/**
 * 
 * @author InteractiveSyllabus
 * 
 * This class contains all of the test cases for the Map object, based on the constructor and methods around.
 *
 */
public class MapTest {
	
	private ImageIcon image = new ImageIcon("canada.jpg");
	private MapPanel panel = new MapPanel(new JSlider());
	private Map canadaMap = new Map(image.getImage(), panel);

	/**
	 * This test just makes sure that JUnit is working.
	 */
	@Test
	public void testJUnit()
	{
		assertTrue("Hope this does not Minge.", true);
	}
	
	/**
	 * This test tests that the Map constructor with no arguements
	 */
	@Test
	public void testMapConstructorWithNoArguements()
	{
		assertNotNull(new Map());
	}
	
	@Test
	public void testMapConstructorWithArguements()
	{
		assertNotNull(new Map(image.getImage(), panel));
	}
	
	@Test
	public void testMapGetMapImage()
	{
		assertNotNull(canadaMap.getMapImage());
	}
	
	@Test
	public void testMapGetZoomLevel()
	{
		assertEquals(canadaMap.getZoomLevel(), 1, 0.0001);
	}
	
	@Test
	public void testMapIncreaseZoom()
	{
		canadaMap.increaseZoom();
		assertEquals(canadaMap.getZoomLevel(), 1.1, 0.0001);
	}
	
	@Test
	public void testMapDecreaseZoom()
	{
		canadaMap.decreaseZoom();
		assertEquals(canadaMap.getZoomLevel(), 0.9, 0.0001);
	}
	
	@Test
	public void testMapGetStartX()
	{
		assertEquals(canadaMap.getStartXCoord(), panel.getWidth() / 2 - (image.getImage().getWidth(null) / 2));
	}
	
	@Test
	public void testMapGetStartY()
	{
		assertEquals(canadaMap.getStartYCoord(), panel.getHeight() / 2 - (image.getImage().getHeight(null) / 2));
	}
	
	@Test
	public void testMapGetEndX()
	{
		assertEquals(canadaMap.getEndXCoord(), canadaMap.getStartXCoord() + image.getIconWidth());
	}
	
	@Test
	public void testMapGetEndY()
	{
		assertEquals(canadaMap.getEndYCoord(), canadaMap.getStartYCoord() + image.getIconHeight());
	}
}
